﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DeepSeekDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            button1.Text = "已发送";
            string Title = this.Text;
            this.Text += " - DeepSeek处理中，请稍后...";

            string input = textInput.Text.Trim();
            Chat(input, respone => { 
                textOutPut.Text = respone;

                button1.Enabled = true;
                button1.Text = "发送";
                this.Text = Title;
            });
        }

        DeepSeekChatService2 chatService = new DeepSeekChatService2();
        public async void Chat(string input,  Action<string> callBack)
        {
            // 使用示例
            var response = await chatService.ChatAsync(input);
            //Console.WriteLine(response);


            /* 预期响应格式示例：
            {
              "choices": [
                {
                  "message": {
                    "role": "assistant",
                    "content": "量子计算是基于量子力学原理..."
                  }
                }
              ]
            }
            */

            if (callBack != null) callBack(response);
        }

        private void text_DoubleClick(object sender, EventArgs e)
        {
            (sender as TextBox).SelectAll();
        }
    }
}
